﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Windsor;
using Castle.MicroKernel.Registration;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IWindsorContainer container=new WindsorContainer())
            {
                container.Register(
                    Component.For<IPerson>().ImplementedBy<Boss>(),
                    Component.For<ICar>().ImplementedBy<MotoCar>(),
                    Component.For<IWork>().ImplementedBy<GotoWork>()
                    );
              var work= container.Resolve<IWork>();
              work.Work();
              Console.ReadKey();
            }
        }
    }

    public interface IPerson
    {
        void ShowName();
    }
    public interface ICar
    {
        void ShowName();
    }
    public class Bike : ICar
    {
        public void ShowName()
        {
            Console.WriteLine("Bike");
        }
    }
    public class MotoCar : ICar
    {
        public void ShowName()
        {
            Console.WriteLine("MotoCar");
        }
    }
    public class Stuff : IPerson
    {
        public void ShowName()
        {
            Console.WriteLine("Stuff");
        }
    }
    public class Boss : IPerson
    {
        public void ShowName()
        {
            Console.WriteLine("Boss");
        }
    }
    public interface IWork
    {
        void Work();
    }
    public class GotoWork:IWork
    {
        private readonly ICar car;
        private readonly IPerson person;
        public GotoWork (IPerson p, ICar c)
        {
            car = c;
            person = p;
        }
        public void Work()
        {
            Console.WriteLine("***********");
            person.ShowName();
            Console.WriteLine("Go to work by =>");
            car.ShowName();
            Console.WriteLine("***********");
        }
    }
}
